package cn.tedu.mapper;

import cn.tedu.pojo.StaffWorktable;
import cn.tedu.vo.WorkCount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.PathVariable;

public interface EmployeeMapper extends BaseMapper<StaffWorktable> {
    @Select("SELECT staff_name staffName, COUNT(add_rent) addRent ,COUNT(active_rent) activeRent,COUNT(active_sail) activeSail,COUNT(whouse) whouse,COUNT(sechouse_token) sechouseToken,COUNT(firhouse_token) firhouseToken,COUNT(renthouse_token) renthouseToken,SUM(daytotal_phone) totalPhone,SUM(daysuccess_phone)  successPhone, COUNT(source) source,COUNT(doorkey) doorkey,COUNT(photo_staff) photoStaff,COUNT(client_source) clientSource,COUNT(second_client) secondClient,COUNT(follow_num) followNum,COUNT(follow_time) followTime,COUNT(source_num) sourceNum,COUNT(source_time) sourceTime FROM staff_worktable WHERE id = #{id} AND to_days(createdTime) = to_days(now());")
    WorkCount countWorkByToday(@PathVariable Integer id);

    @Select("SELECT staff_name staffName, COUNT(add_rent) addRent ,COUNT(active_rent) activeRent,COUNT(active_sail) activeSail,COUNT(whouse) whouse,COUNT(sechouse_token) sechouseToken,COUNT(firhouse_token) firhouseToken,COUNT(renthouse_token) renthouseToken,SUM(daytotal_phone) totalPhone,SUM(daysuccess_phone)  successPhone, COUNT(source) source,COUNT(doorkey) doorkey,COUNT(photo_staff) photoStaff,COUNT(client_source) clientSource,COUNT(second_client) secondClient,COUNT(follow_num) followNum,COUNT(follow_time) followTime,COUNT(source_num) sourceNum,COUNT(source_time) sourceTime FROM staff_worktable WHERE id = #{id} AND DATE_FORMAT( createdTime, '%u' ) = DATE_FORMAT( CURDATE( ) , '%u' )")
    WorkCount countWorkByWeek(@PathVariable Integer id);

    @Select("SELECT staff_name staffName, COUNT(add_rent) addRent ,COUNT(active_rent) activeRent,COUNT(active_sail) activeSail,COUNT(whouse) whouse,COUNT(sechouse_token) sechouseToken,COUNT(firhouse_token) firhouseToken,COUNT(renthouse_token) renthouseToken,SUM(daytotal_phone) totalPhone,SUM(daysuccess_phone)  successPhone, COUNT(source) source,COUNT(doorkey) doorkey,COUNT(photo_staff) photoStaff,COUNT(client_source) clientSource,COUNT(second_client) secondClient,COUNT(follow_num) followNum,COUNT(follow_time) followTime,COUNT(source_num) sourceNum,COUNT(source_time) sourceTime FROM staff_worktable WHERE id = #{id} AND DATE_FORMAT( createdTime, '%Y-%m' ) = DATE_FORMAT( CURDATE( ) , '%Y-%m' )")
    WorkCount countWorkByMonth(@PathVariable Integer id);

    @Select("SELECT staff_name staffName, COUNT(add_rent) addRent ,COUNT(active_rent) activeRent,COUNT(active_sail) activeSail,COUNT(whouse) whouse,COUNT(sechouse_token) sechouseToken,COUNT(firhouse_token) firhouseToken,COUNT(renthouse_token) renthouseToken,SUM(daytotal_phone) totalPhone,SUM(daysuccess_phone)  successPhone, COUNT(source) source,COUNT(doorkey) doorkey,COUNT(photo_staff) photoStaff,COUNT(client_source) clientSource,COUNT(second_client) secondClient,COUNT(follow_num) followNum,COUNT(follow_time) followTime,COUNT(source_num) sourceNum,COUNT(source_time) sourceTime FROM staff_worktable WHERE id = #{id} AND to_days(createdTime) = to_days(#{time});")
    WorkCount countWorkByTime(@PathVariable String time, @PathVariable Integer id);
}
